{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Vizualizing meandering with Python\n",
    "\n",
    "Inspired from work of Zoltán Sylvester,Bureau of Economic Geology, and made with Dr. Al Ibrahim for Quantitative Sequence Stratigraphy project.\n",
    "\n",
    "Added features: \n",
    "1. Stream cutoff when segments meet, forming an ox-bow lake.\n",
    "2. Removed achoring artifact.\n",
    "3. Width added to the river.\n",
    "4. Aggradation (basw level rising due to deposition of sediments) incorporated."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from math import pi\n",
    "from ipywidgets import interact, interactive, fixed\n",
    "import ipywidgets as widgets\n",
    "import scipy.interpolate\n",
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "plt.rcParams[\"figure.figsize\"] = (9,6) # set the default figure size to (9,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x202b032a488>]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAFlCAYAAAA5w+hdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nOzdd1iV9f/H8dd9OHDYQ/YSEAXELYgzR+49MrXMSk0rtWl72C5b38osK7MclTM1994bcICCgyFL9pRxOBzu+/fHUX/uebjf9zm8H9fVdX1T4vO0b8Lbe3w+giRJYIwxxhijoqIOYIwxxlj9xsMIY4wxxkjxMMIYY4wxUjyMMMYYY4wUDyOMMcYYI8XDCGOMMcZIqakDbsXNzU0KDAykzmCMMcaYkcTGxhZIkuR+/Y8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RRuexNaXUYSBaa+20628opeYDv2qt59Rs+uqltT5ldC57qPl/5CgQo7W213pf/6PB9oxorfdqrfcbncMO+gBpWutDWutK4GtgtMGZbEprvRE4aXQOe9JaH9NaJ9d8f5ozm0y2MDaVbekzimueutY8nO63I6VUKHANMMfoLOLSKKX8gIHApwBa60pnLURqXAkcrKtCBBpwMeLEWgCZf3iehZP9J9bQKKVaAT2ABGOT2F7N8MV2IBdYrbV2umsE3gWmcaYn1llpYJVSKkkpdbfRYeygNZAHzK0ZbpujlPI2OpQd3QJ8VZcNOnUxopRao5TadZaHU/UU/Ik6y2tO99tmQ6GU8gEWA1O11kVG57E1rbVFax0FhAJ9lFJONeymlBoJ5Gqtk4zOYmf9tdY9geHAfTVDqc7EDPQEPtJa9wBKAKebjwdQMwR1LbCoLts112VjdU1rPcToDAbIAsL+8DwUyDYoi6iFmnkUi4EvtNbfGZ3HnrTWp5RSG4CrAWeamNwfuFYpNQLwAPyUUgu11rcanMumtNbZNV9zlVLfc2a4eKOxqWwqC8j6Q8/dtzhpMcKZgjJZa328Lht16p6RBmor0E4pFVFT4d4CLDU4k7hINZM7PwX2aq3fMTqPPSilgpRS/jXfewJDgH3GprItrfUTWutQrXUrzvxbXOdshYhSyrtmkjU1QxdDca6CEq11DpCplOpQ89KVgNNMJv+TcdTxEA004GJEKTVGKZUFxALLlFIrjc5kC1rrauB+YCVnJj1+o7XebWwq21JKfQXEAR2UUllKqTuNzmQH/YEJwOA/3Go3wuhQNtYcWK+U2sGZInq11topb311cs2A35RSKcAWYJnW+meDM9nDFOCLmp/XKOAVg/PYnFLKizN3YtZ5T2yDvbVXCCGEEPVDg+0ZEUIIIUT9IMWIEEIIIQwlxYgQQgghDCXFiBBCCCEMJcWIEEIIIQwlxYgQQgghDCXFiBBCCCEMJcWIEEIIIQz1/wDcSVvOrbapPgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 648x432 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# based on https://www.mathworks.com/matlabcentral/fileexchange/13351-fast-and-robust-self-intersections\n",
    "def selfIntersect(x,y):\n",
    "    # Create output\n",
    "    x0=[];\n",
    "    y0=[];\n",
    "    \n",
    "    segments=[];\n",
    "\n",
    "    # Two similar curves are firstly created.\n",
    "    x1=x; x2=x;\n",
    "    y1=y; y2=y;\n",
    "\n",
    "    # Compute number of line segments in each curve and some differences we'll need later.\n",
    "    n1 = len(x1) - 1;\n",
    "    n2 = len(x2) - 1;\n",
    "\n",
    "    dxy1 = np.diff(np.array([x1, y1]).T, axis=0);\n",
    "    dxy2 = np.diff(np.array([x2, y2]).T, axis=0);\n",
    "\n",
    "\n",
    "    # Determine the combinations of i and j where the rectangle enclosing the\n",
    "    # i'th line segment of curve 1 overlaps with the rectangle enclosing the\n",
    "    # j'th line segment of curve 2.\n",
    "    r1 = np.tile(np.min(np.array([x1[0:-1],x1[1:]]).T, axis=1),[n2,1]).T\n",
    "    r2 = np.tile(np.max(np.array([x2[0:-1],x2[1:]]).T, axis=1),[n1,1])\n",
    "    r3 = np.tile(np.max(np.array([x1[0:-1],x1[1:]]).T, axis=1),[n2,1]).T\n",
    "    r4 = np.tile(np.min(np.array([x2[0:-1],x2[1:]]).T, axis=1),[n1,1])\n",
    "    r5 = np.tile(np.min(np.array([y1[0:-1],y1[1:]]).T, axis=1),[n2,1]).T\n",
    "    r6 = np.tile(np.max(np.array([y2[0:-1],y2[1:]]).T, axis=1),[n1,1])\n",
    "    r7 = np.tile(np.max(np.array([y1[0:-1],y1[1:]]).T, axis=1),[n2,1]).T\n",
    "    r8 = np.tile(np.min(np.array([y2[0:-1],y2[1:]]).T, axis=1),[n1,1])\n",
    "    [j, i] = np.where(np.logical_and(np.logical_and(r1<=r2, r3>=r4), np.logical_and(r5<=r6, r7>=r8)))\n",
    "    # Removing coincident and adjacent segments.\n",
    "    \n",
    "    remove=np.where(np.abs(i-j)<2)\n",
    "    i = np.delete(i, remove)\n",
    "    j = np.delete(j, remove)\n",
    "    \n",
    "\n",
    "    # Removing duplicate combinations of segments.\n",
    "    remove=np.array([], dtype='int');\n",
    "    for ii in range(0, len(i)):\n",
    "        ind = np.where(np.logical_and((i[ii]==j[ii:]), j[ii]==i[ii:]));\n",
    "        ind = np.array(ind);\n",
    "        remove= np.append(remove,ii+ind)\n",
    "    i = np.delete(i, remove)\n",
    "    j = np.delete(j, remove)\n",
    "\n",
    "\n",
    "    # Find segments pairs which have at least one vertex = NaN and remove them.\n",
    "    # This line is a fast way of finding such segment pairs.  We take\n",
    "    # advantage of the fact that NaNs propagate through calculations, in\n",
    "    # particular subtraction (in the calculation of dxy1 and dxy2, which we\n",
    "    # need anyway) and addition.\n",
    "    remove = np.where(np.isnan(np.sum(dxy1[i,:] + dxy2[j,:],axis=1)));\n",
    "    i = np.delete(i, remove)\n",
    "    j = np.delete(j, remove)\n",
    "\n",
    "\n",
    "    xNew = np.copy(x)\n",
    "    yNew = np.copy(y)\n",
    "    xCut = np.copy(x)\n",
    "    yCut = np.copy(y)\n",
    "\n",
    "    remove=np.array([], dtype='int');\n",
    "    for ii in range(0,len(i)):\n",
    "        remove = np.append(remove, np.arange(j[ii]+1,i[ii]+1))\n",
    "    xNew = np.delete(xNew, remove)\n",
    "    yNew = np.delete(yNew, remove)\n",
    "    \n",
    "    keep = np.setdiff1d(np.array(np.arange(0,len(x))), remove)\n",
    "    xCut[keep] = np.nan\n",
    "    yCut[keep] = np.nan\n",
    "    \n",
    "    return xNew, yNew, xCut, yCut, keep\n",
    "\n",
    "#Examplr/test\n",
    "# Create the data\n",
    "N=201;\n",
    "th=np.linspace(-3*pi,4*pi,N);\n",
    "R=1;\n",
    "x=R*np.cos(th)+np.linspace(0,6,N);\n",
    "y=R*np.sin(th)+np.linspace(0,1,N);\n",
    "\n",
    "xNew, yNew, xCut, yCut, keep = selfIntersect(x,y)\n",
    "plt.figure()\n",
    "plt.plot(x,y)\n",
    "plt.plot(xNew,yNew)\n",
    "plt.plot(xCut, yCut, 'k')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Convolution (Howard & Knutson) model\n",
    "\n",
    "\n",
    "All three approaches discussed so far are just geometric curves; and there is no easy way to construct a sequence of centerlines that would correpsond to the long-term evolution of a channel (although it is not that difficult to construct a series of lines of increasing sinuosity, with no downstream variability in meander bends). All actual forward models of meandering channels rely on linking the lateral migration rate to channel curvature. Models that link the lateral migration rate to the excess velocity along channel banks suggest that it is not only the lcoal curavture that determines the excess velocity (and therefore migration rate), but curvatures at upstream locations need to be considered as well, with upstream decreasing influence. The simplest meandering model links migration rates directly to curvatures (without calculating velocities) and was described by Howard and Knuston (Howard, A.D., and Knutson, T., 1984, Sufficient Conditions for River Meandering: A Simulation Approach: Water Resources Research, v. 20, no. 11, p. 1659–1667). The following script is a bare-bones Python implementation of the Howard & Knutson model.\n",
    "\n",
    "The Howard and Knutson model is based on the calculation of an adjusted channel migration rate $R_1$ from a nominal migration rate $R_0$, using a weighting function $G(\\xi)$:\n",
    "\n",
    "$$ R_1(s) = \\Omega R_0(s) + \\Big(\\Gamma \\int_{0}^{\\infty}R_0(s-\\xi)G(\\xi)d\\xi\\Big) \\Big(\\int_{0}^{\\infty}G(\\xi)d\\xi\\Big)^{-1} $$\n",
    "\n",
    "$$ R_0 = k_l \\frac{W}{R} $$\n",
    "                                                  \n",
    "where $R_0(s)$ and $R_0(s-\\xi)$ are the nominal migration rates at locations $s$ and at a distance $\\xi$ upstream from $s$, respectively. \\Omega and \\Gamma are weighting parameters that are set to -1 and 2.5 respectively, to produce one of the two parameterizations of stable meandering (Howard and Knutson, 1984). $G(\\xi)$ is a weighting function that decreases exponentially in the upstream direction:\n",
    "\n",
    "$$ G(\\xi) = e^{-\\alpha\\xi} $$\n",
    "\n",
    "For additional details see the supplementary material to the following paper: Sylvester, Z., and Covault, J.A., 2016, Development of cutoff-related knickpoints during early evolution of submarine channels: Geology, v. 44, no. 10, p. 835–838, doi: 10.1130/G38397.1.\n",
    "\n",
    "Note that the script below does not address meander cutoffs; once the centerline starts intersecting itself, the results are meaningless. The way cutoffs are treated is an important (and non-trivial) part of a long-term evolution model."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Run model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Compare curvature and wavelength. Distribution of curvature. Change noise. How does changing width change origninal results\n",
    "# Effect of changing slope in k\n",
    "import matplotlib.path as mpltPath\n",
    "\n",
    "agg_rate = 1.0 # Added\n",
    "D = 5.0 # channel depth in meters\n",
    "W = D*20.0 # channel width in meters\n",
    "kl = 1.5E-7 # lateral erosion rate constant (m/s) \n",
    "dt = 6*30*24*60*60 * W/100 # time step in seconds (~ 6 months for W = 100 m)\n",
    "Cf1 = 0.03 # dimensionless Chezy friction factor\n",
    "Cf2 = 0.04 # Say different for different lithology\n",
    "nit = 1000 # number of time steps\n",
    "saved_ts = 1 # every 'saved_ts' time step is saved \n",
    "delta_s = W*0.25\n",
    "noisy_len = 8000 # length of noisy part of initial centerline\n",
    "pLeft = 20 # length of padding (no noise on this)\n",
    "pRight = 2\n",
    "k = 1 # constant in equation for exponent in curvature calculation \n",
    "omega = -1.0 # constant in curvature calculation (Howard and Knutson, 1984)\n",
    "gamma = 2.5 # from Ikeda et al., 1981 and Howard and Knutson, 1984\n",
    "# alpha = k*2*Cf/D # exponent for convolution function G\n",
    "p=[]\n",
    "# CREATE INITIAL CENTERLINE COORDINATES\n",
    "x = np.linspace(0, noisy_len+(pLeft+pRight)*delta_s, int(noisy_len/delta_s+(pLeft+pRight))+1) \n",
    "y = 1.0 * (2*np.random.random_sample(int(noisy_len/delta_s)+1,)-1)\n",
    "ypadLeft = np.zeros((pLeft),)\n",
    "ypadRight = np.zeros((pRight),)\n",
    "y = np.hstack((ypadLeft,y,ypadRight))\n",
    "\n",
    "dx = np.diff(x); dy = np.diff(y)      \n",
    "ds = np.sqrt(dx**2+dy**2) # initial distances between points along centerline\n",
    "dxMax = dx[0];\n",
    "\n",
    "# LISTS FOR STORING RESULTS\n",
    "X, Y = [], []\n",
    "X1, Y1 = [], []\n",
    "X2, Y2 = [], []\n",
    "OXBOWX, OXBOWY = [], []\n",
    "CURVATURE = []\n",
    "MIGRATION_RATE=[]\n",
    "NOMINAL_MIGRATION_RATE=[]\n",
    "TIME = []\n",
    "\n",
    "#X.append(x)\n",
    "#Y.append(y)\n",
    "#cut = np.zeros_like(x)*np.nan\n",
    "#OXBOWX.append(cut)\n",
    "#OXBOWY.append(cut)\n",
    "\n",
    "yCut = []\n",
    "xCut = []\n",
    "\n",
    "\n",
    "for itn in range(1,nit): # main loop\n",
    "    ns=len(x)    \n",
    "    \n",
    "    # COMPUTE CURVATURE\n",
    "    ddx = np.diff(dx); ddy = np.diff(dy);      \n",
    "    curv = W*(dx[1:]*ddy-dy[1:]*ddx)/((dx[1:]**2+dy[1:]**2)**1.5) # curvature\n",
    "    # COMPUTE MIGRATION RATE\n",
    "    R0 = kl*curv # nominal migration rate\n",
    "    R1 = np.zeros(ns-2) # preallocate adjusted channel migration rate\n",
    "    \n",
    "    #%% Added 31/1/19 Boundaries of the stream\n",
    "    dx = np.diff(x); dy = np.diff(y); dx = np.append(dx[0],dx); dy = np.append(dy[0],dy)\n",
    "    ddx = np.diff(dx); ddy = np.diff(dy)\n",
    "    t = np.arctan(dy/dx)\n",
    "    x1 = x + W *np.sin(t)*np.sign(dx)\n",
    "    y1 = y - W *np.cos(t)*np.sign(dx)\n",
    "    x2 = x - W *np.sin(t)*np.sign(dx)\n",
    "    y2 = y + W *np.cos(t)*np.sign(dx)\n",
    "    #%%\n",
    "    \n",
    "    for i in range(pLeft,ns-pRight):\n",
    "        \n",
    "        #%% Added erosion, change Cf\n",
    "        inside = False #reset\n",
    "        if itn > D*agg_rate:\n",
    "            for past_time in range(1,int(D*agg_rate+1)):\n",
    "                xp1 = X1[-past_time]; yp1 = Y1[-past_time]; \n",
    "                xp2r = X2[-past_time][::-1]; yp2r = Y2[-past_time][::-1] #reverse order\n",
    "        \n",
    "                # Create polygon\n",
    "                xp = np.hstack((xp1,xp2r)); yp = np.hstack((yp1, yp2r));\n",
    "                xy = np.array([xp,yp]).T\n",
    "                path = mpltPath.Path(xy)\n",
    "                \n",
    "                #Eroding side\n",
    "                if curv[i]<0: inside2 = path.contains_points([[x1[i],y1[i]]])\n",
    "                else: inside2 = path.contains_points([[x2[i],y2[i]]])\n",
    "                    \n",
    "            inside = inside or inside2    \n",
    "                    \n",
    "        if inside==True: Cf = Cf2\n",
    "        else: Cf = Cf1\n",
    "        #%%\n",
    "        \n",
    "        \n",
    "        alpha = k*2*Cf/D # exponent for convolution function G\n",
    "        si2 = np.cumsum(ds[i::-1]) # distance along centerline, backwards from current point\n",
    "        G = np.exp(-alpha*si2) # convolution vector\n",
    "        R1[i-1] = omega*R0[i-1] + gamma*np.sum(R0[i-1::-1]*G[:-1])/np.sum(G[:-1]) # adjusted migration rate\n",
    "    # COMPUTE NEW COORDINATES\n",
    "    x[pLeft:ns-pRight] = x[pLeft:ns-pRight] + R1[pLeft-1:ns-pRight-1]*dt*np.diff(y[pLeft:ns-pRight+1])/ds[pLeft:ns-pRight]\n",
    "    y[pLeft:ns-pRight] = y[pLeft:ns-pRight] - R1[pLeft-1:ns-pRight-1]*dt*np.diff(x[pLeft:ns-pRight+1])/ds[pLeft:ns-pRight]   \n",
    "    \n",
    "    y[ns-pRight-pRight:] = y[ns-pRight-pRight:]*0+y[ns-pRight-pRight-1] \n",
    "#     x, y, xCut, yCut  = selfIntersect(x,y)\n",
    "    \n",
    "\n",
    "    #%% Added 31/1/19\n",
    "    x1New, y1New, x1Cut, y1Cut, keep1 = selfIntersect(x1,y1)\n",
    "    x2New, y2New, x2Cut, y2Cut, keep2 = selfIntersect(x2,y2)\n",
    "    keep = sorted(list(set(keep1) & set(keep2)))\n",
    "    x = x[keep]; y = y[keep]\n",
    "    #%%\n",
    "    \n",
    "    # RESAMPLE CENTERLINE\n",
    "    tck, u = scipy.interpolate.splprep([x,y],s=0) # parametric spline representation of curve (for resampling)\n",
    "    unew = np.linspace(0,1,1+int(np.sum(ds)/delta_s)) # vector for resampling\n",
    "    out = scipy.interpolate.splev(unew,tck) # actual resampling\n",
    "    x = out[0]\n",
    "    y = out[1]\n",
    "    \n",
    "    # COMPUTE DISTANCES BETWEEN NEW POINTS\n",
    "    dx = np.diff(x); dy = np.diff(y)      \n",
    "    ds = np.sqrt(dx**2+dy**2) # distances between points along centerline\n",
    "    # STORE RESULTS\n",
    "    if np.mod(itn,saved_ts)==0:\n",
    "        X.append(x)\n",
    "        Y.append(y)\n",
    "        X1.append(x1); Y1.append(y1); X2.append(x2); Y2.append(y2)\n",
    "        OXBOWX.append(xCut)\n",
    "        OXBOWY.append(yCut)\n",
    "        CURVATURE.append(curv)\n",
    "        TIME.append(itn)\n",
    "        MIGRATION_RATE.append(R1)\n",
    "        NOMINAL_MIGRATION_RATE.append(R0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "3dde6ade50454b01a0e25f1151f13caf",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=0, description='ts', max=998, step=30), IntSlider(value=0, description='…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "backInTime = 400\n",
    "\n",
    "@interact(ts=(0,len(X)-1,30),xloc=(-1000,7000,50),zoom=(-5000,5000,100))\n",
    "def plot_clines(ts=0,xloc=0,zoom=-2000):\n",
    "    fig = plt.figure(num=None, figsize=(14, 6), dpi=80, facecolor='w', edgecolor='k')\n",
    "    ax = plt.axes()\n",
    "    plt.text(0.01, 0.95, 'Timestep: ' + str(TIME[ts]), horizontalalignment='left', verticalalignment='top', transform=ax.transAxes, fontsize=28)\n",
    "    plt.text(.025, .57, 'Flow', horizontalalignment='left', verticalalignment='bottom', fontsize=20, transform=ax.transAxes)\n",
    "    ax.arrow(.005, .55, .1,0, width = .01, head_width=.05, head_length=.01, fc='k', ec='k', transform=ax.transAxes)\n",
    "\n",
    "    startTime = np.max(np.array([0,ts-backInTime]))\n",
    "    j = 1.05\n",
    "    for i in np.arange(startTime,ts,20):\n",
    "        j = j-0.05\n",
    "        plt.plot(X[i],Y[i],lw=1,color=(0.9*j,0.9*j,0.9*j)) #Changed 31/1\n",
    "    for i in np.arange(startTime,ts,1):\n",
    "        if np.any(~np.isnan(OXBOWX[i])):\n",
    "            plt.plot(OXBOWX[i],OXBOWY[i],lw=2,color=(1,.7,0))\n",
    "        \n",
    "    plt.plot(X[ts],Y[ts],lw=2,color=(0.04,0.37,0.59))\n",
    "    plt.plot(X1[ts],Y1[ts],lw=2,color=(1,0,0))\n",
    "    plt.plot(X2[ts],Y2[ts],lw=2,color=(0,1,0))\n",
    "    plt.plot(OXBOWX[ts],OXBOWY[ts],lw=6,color=(1,.7,0))\n",
    "#     plt.xticks([]) \n",
    "#     plt.yticks([])\n",
    "    plt.xlim(xloc,np.max(X[0][-1])+800)\n",
    "    plt.ylim(-(3000-zoom)/3.0,(3000-zoom)/3.0)\n",
    "    plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c1ef7e8e701e4913b5b99af539dd852a",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=0, description='ts', max=998, step=30), IntSlider(value=0, description='…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "/* Put everything inside the global mpl namespace */\n",
       "window.mpl = {};\n",
       "\n",
       "\n",
       "mpl.get_websocket_type = function() {\n",
       "    if (typeof(WebSocket) !== 'undefined') {\n",
       "        return WebSocket;\n",
       "    } else if (typeof(MozWebSocket) !== 'undefined') {\n",
       "        return MozWebSocket;\n",
       "    } else {\n",
       "        alert('Your browser does not have WebSocket support. ' +\n",
       "              'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
       "              'Firefox 4 and 5 are also supported but you ' +\n",
       "              'have to enable WebSockets in about:config.');\n",
       "    };\n",
       "}\n",
       "\n",
       "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
       "    this.id = figure_id;\n",
       "\n",
       "    this.ws = websocket;\n",
       "\n",
       "    this.supports_binary = (this.ws.binaryType != undefined);\n",
       "\n",
       "    if (!this.supports_binary) {\n",
       "        var warnings = document.getElementById(\"mpl-warnings\");\n",
       "        if (warnings) {\n",
       "            warnings.style.display = 'block';\n",
       "            warnings.textContent = (\n",
       "                \"This browser does not support binary websocket messages. \" +\n",
       "                    \"Performance may be slow.\");\n",
       "        }\n",
       "    }\n",
       "\n",
       "    this.imageObj = new Image();\n",
       "\n",
       "    this.context = undefined;\n",
       "    this.message = undefined;\n",
       "    this.canvas = undefined;\n",
       "    this.rubberband_canvas = undefined;\n",
       "    this.rubberband_context = undefined;\n",
       "    this.format_dropdown = undefined;\n",
       "\n",
       "    this.image_mode = 'full';\n",
       "\n",
       "    this.root = $('<div/>');\n",
       "    this._root_extra_style(this.root)\n",
       "    this.root.attr('style', 'display: inline-block');\n",
       "\n",
       "    $(parent_element).append(this.root);\n",
       "\n",
       "    this._init_header(this);\n",
       "    this._init_canvas(this);\n",
       "    this._init_toolbar(this);\n",
       "\n",
       "    var fig = this;\n",
       "\n",
       "    this.waiting = false;\n",
       "\n",
       "    this.ws.onopen =  function () {\n",
       "            fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n",
       "            fig.send_message(\"send_image_mode\", {});\n",
       "            if (mpl.ratio != 1) {\n",
       "                fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n",
       "            }\n",
       "            fig.send_message(\"refresh\", {});\n",
       "        }\n",
       "\n",
       "    this.imageObj.onload = function() {\n",
       "            if (fig.image_mode == 'full') {\n",
       "                // Full images could contain transparency (where diff images\n",
       "                // almost always do), so we need to clear the canvas so that\n",
       "                // there is no ghosting.\n",
       "                fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
       "            }\n",
       "            fig.context.drawImage(fig.imageObj, 0, 0);\n",
       "        };\n",
       "\n",
       "    this.imageObj.onunload = function() {\n",
       "        fig.ws.close();\n",
       "    }\n",
       "\n",
       "    this.ws.onmessage = this._make_on_message_function(this);\n",
       "\n",
       "    this.ondownload = ondownload;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_header = function() {\n",
       "    var titlebar = $(\n",
       "        '<div class=\"ui-dialog-titlebar ui-widget-header ui-corner-all ' +\n",
       "        'ui-helper-clearfix\"/>');\n",
       "    var titletext = $(\n",
       "        '<div class=\"ui-dialog-title\" style=\"width: 100%; ' +\n",
       "        'text-align: center; padding: 3px;\"/>');\n",
       "    titlebar.append(titletext)\n",
       "    this.root.append(titlebar);\n",
       "    this.header = titletext[0];\n",
       "}\n",
       "\n",
       "\n",
       "\n",
       "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n",
       "\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n",
       "\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_canvas = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var canvas_div = $('<div/>');\n",
       "\n",
       "    canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n",
       "\n",
       "    function canvas_keyboard_event(event) {\n",
       "        return fig.key_event(event, event['data']);\n",
       "    }\n",
       "\n",
       "    canvas_div.keydown('key_press', canvas_keyboard_event);\n",
       "    canvas_div.keyup('key_release', canvas_keyboard_event);\n",
       "    this.canvas_div = canvas_div\n",
       "    this._canvas_extra_style(canvas_div)\n",
       "    this.root.append(canvas_div);\n",
       "\n",
       "    var canvas = $('<canvas/>');\n",
       "    canvas.addClass('mpl-canvas');\n",
       "    canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n",
       "\n",
       "    this.canvas = canvas[0];\n",
       "    this.context = canvas[0].getContext(\"2d\");\n",
       "\n",
       "    var backingStore = this.context.backingStorePixelRatio ||\n",
       "\tthis.context.webkitBackingStorePixelRatio ||\n",
       "\tthis.context.mozBackingStorePixelRatio ||\n",
       "\tthis.context.msBackingStorePixelRatio ||\n",
       "\tthis.context.oBackingStorePixelRatio ||\n",
       "\tthis.context.backingStorePixelRatio || 1;\n",
       "\n",
       "    mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
       "\n",
       "    var rubberband = $('<canvas/>');\n",
       "    rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n",
       "\n",
       "    var pass_mouse_events = true;\n",
       "\n",
       "    canvas_div.resizable({\n",
       "        start: function(event, ui) {\n",
       "            pass_mouse_events = false;\n",
       "        },\n",
       "        resize: function(event, ui) {\n",
       "            fig.request_resize(ui.size.width, ui.size.height);\n",
       "        },\n",
       "        stop: function(event, ui) {\n",
       "            pass_mouse_events = true;\n",
       "            fig.request_resize(ui.size.width, ui.size.height);\n",
       "        },\n",
       "    });\n",
       "\n",
       "    function mouse_event_fn(event) {\n",
       "        if (pass_mouse_events)\n",
       "            return fig.mouse_event(event, event['data']);\n",
       "    }\n",
       "\n",
       "    rubberband.mousedown('button_press', mouse_event_fn);\n",
       "    rubberband.mouseup('button_release', mouse_event_fn);\n",
       "    // Throttle sequential mouse events to 1 every 20ms.\n",
       "    rubberband.mousemove('motion_notify', mouse_event_fn);\n",
       "\n",
       "    rubberband.mouseenter('figure_enter', mouse_event_fn);\n",
       "    rubberband.mouseleave('figure_leave', mouse_event_fn);\n",
       "\n",
       "    canvas_div.on(\"wheel\", function (event) {\n",
       "        event = event.originalEvent;\n",
       "        event['data'] = 'scroll'\n",
       "        if (event.deltaY < 0) {\n",
       "            event.step = 1;\n",
       "        } else {\n",
       "            event.step = -1;\n",
       "        }\n",
       "        mouse_event_fn(event);\n",
       "    });\n",
       "\n",
       "    canvas_div.append(canvas);\n",
       "    canvas_div.append(rubberband);\n",
       "\n",
       "    this.rubberband = rubberband;\n",
       "    this.rubberband_canvas = rubberband[0];\n",
       "    this.rubberband_context = rubberband[0].getContext(\"2d\");\n",
       "    this.rubberband_context.strokeStyle = \"#000000\";\n",
       "\n",
       "    this._resize_canvas = function(width, height) {\n",
       "        // Keep the size of the canvas, canvas container, and rubber band\n",
       "        // canvas in synch.\n",
       "        canvas_div.css('width', width)\n",
       "        canvas_div.css('height', height)\n",
       "\n",
       "        canvas.attr('width', width * mpl.ratio);\n",
       "        canvas.attr('height', height * mpl.ratio);\n",
       "        canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n",
       "\n",
       "        rubberband.attr('width', width);\n",
       "        rubberband.attr('height', height);\n",
       "    }\n",
       "\n",
       "    // Set the figure to an initial 600x600px, this will subsequently be updated\n",
       "    // upon first draw.\n",
       "    this._resize_canvas(600, 600);\n",
       "\n",
       "    // Disable right mouse context menu.\n",
       "    $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n",
       "        return false;\n",
       "    });\n",
       "\n",
       "    function set_focus () {\n",
       "        canvas.focus();\n",
       "        canvas_div.focus();\n",
       "    }\n",
       "\n",
       "    window.setTimeout(set_focus, 100);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_toolbar = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var nav_element = $('<div/>');\n",
       "    nav_element.attr('style', 'width: 100%');\n",
       "    this.root.append(nav_element);\n",
       "\n",
       "    // Define a callback function for later on.\n",
       "    function toolbar_event(event) {\n",
       "        return fig.toolbar_button_onclick(event['data']);\n",
       "    }\n",
       "    function toolbar_mouse_event(event) {\n",
       "        return fig.toolbar_button_onmouseover(event['data']);\n",
       "    }\n",
       "\n",
       "    for(var toolbar_ind in mpl.toolbar_items) {\n",
       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
       "\n",
       "        if (!name) {\n",
       "            // put a spacer in here.\n",
       "            continue;\n",
       "        }\n",
       "        var button = $('<button/>');\n",
       "        button.addClass('ui-button ui-widget ui-state-default ui-corner-all ' +\n",
       "                        'ui-button-icon-only');\n",
       "        button.attr('role', 'button');\n",
       "        button.attr('aria-disabled', 'false');\n",
       "        button.click(method_name, toolbar_event);\n",
       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
       "\n",
       "        var icon_img = $('<span/>');\n",
       "        icon_img.addClass('ui-button-icon-primary ui-icon');\n",
       "        icon_img.addClass(image);\n",
       "        icon_img.addClass('ui-corner-all');\n",
       "\n",
       "        var tooltip_span = $('<span/>');\n",
       "        tooltip_span.addClass('ui-button-text');\n",
       "        tooltip_span.html(tooltip);\n",
       "\n",
       "        button.append(icon_img);\n",
       "        button.append(tooltip_span);\n",
       "\n",
       "        nav_element.append(button);\n",
       "    }\n",
       "\n",
       "    var fmt_picker_span = $('<span/>');\n",
       "\n",
       "    var fmt_picker = $('<select/>');\n",
       "    fmt_picker.addClass('mpl-toolbar-option ui-widget ui-widget-content');\n",
       "    fmt_picker_span.append(fmt_picker);\n",
       "    nav_element.append(fmt_picker_span);\n",
       "    this.format_dropdown = fmt_picker[0];\n",
       "\n",
       "    for (var ind in mpl.extensions) {\n",
       "        var fmt = mpl.extensions[ind];\n",
       "        var option = $(\n",
       "            '<option/>', {selected: fmt === mpl.default_extension}).html(fmt);\n",
       "        fmt_picker.append(option);\n",
       "    }\n",
       "\n",
       "    // Add hover states to the ui-buttons\n",
       "    $( \".ui-button\" ).hover(\n",
       "        function() { $(this).addClass(\"ui-state-hover\");},\n",
       "        function() { $(this).removeClass(\"ui-state-hover\");}\n",
       "    );\n",
       "\n",
       "    var status_bar = $('<span class=\"mpl-message\"/>');\n",
       "    nav_element.append(status_bar);\n",
       "    this.message = status_bar[0];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.request_resize = function(x_pixels, y_pixels) {\n",
       "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
       "    // which will in turn request a refresh of the image.\n",
       "    this.send_message('resize', {'width': x_pixels, 'height': y_pixels});\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.send_message = function(type, properties) {\n",
       "    properties['type'] = type;\n",
       "    properties['figure_id'] = this.id;\n",
       "    this.ws.send(JSON.stringify(properties));\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.send_draw_message = function() {\n",
       "    if (!this.waiting) {\n",
       "        this.waiting = true;\n",
       "        this.ws.send(JSON.stringify({type: \"draw\", figure_id: this.id}));\n",
       "    }\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
       "    var format_dropdown = fig.format_dropdown;\n",
       "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
       "    fig.ondownload(fig, format);\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype.handle_resize = function(fig, msg) {\n",
       "    var size = msg['size'];\n",
       "    if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {\n",
       "        fig._resize_canvas(size[0], size[1]);\n",
       "        fig.send_message(\"refresh\", {});\n",
       "    };\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n",
       "    var x0 = msg['x0'] / mpl.ratio;\n",
       "    var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n",
       "    var x1 = msg['x1'] / mpl.ratio;\n",
       "    var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n",
       "    x0 = Math.floor(x0) + 0.5;\n",
       "    y0 = Math.floor(y0) + 0.5;\n",
       "    x1 = Math.floor(x1) + 0.5;\n",
       "    y1 = Math.floor(y1) + 0.5;\n",
       "    var min_x = Math.min(x0, x1);\n",
       "    var min_y = Math.min(y0, y1);\n",
       "    var width = Math.abs(x1 - x0);\n",
       "    var height = Math.abs(y1 - y0);\n",
       "\n",
       "    fig.rubberband_context.clearRect(\n",
       "        0, 0, fig.canvas.width / mpl.ratio, fig.canvas.height / mpl.ratio);\n",
       "\n",
       "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_figure_label = function(fig, msg) {\n",
       "    // Updates the figure title.\n",
       "    fig.header.textContent = msg['label'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_cursor = function(fig, msg) {\n",
       "    var cursor = msg['cursor'];\n",
       "    switch(cursor)\n",
       "    {\n",
       "    case 0:\n",
       "        cursor = 'pointer';\n",
       "        break;\n",
       "    case 1:\n",
       "        cursor = 'default';\n",
       "        break;\n",
       "    case 2:\n",
       "        cursor = 'crosshair';\n",
       "        break;\n",
       "    case 3:\n",
       "        cursor = 'move';\n",
       "        break;\n",
       "    }\n",
       "    fig.rubberband_canvas.style.cursor = cursor;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_message = function(fig, msg) {\n",
       "    fig.message.textContent = msg['message'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_draw = function(fig, msg) {\n",
       "    // Request the server to send over a new figure.\n",
       "    fig.send_draw_message();\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_image_mode = function(fig, msg) {\n",
       "    fig.image_mode = msg['mode'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.updated_canvas_event = function() {\n",
       "    // Called whenever the canvas gets updated.\n",
       "    this.send_message(\"ack\", {});\n",
       "}\n",
       "\n",
       "// A function to construct a web socket function for onmessage handling.\n",
       "// Called in the figure constructor.\n",
       "mpl.figure.prototype._make_on_message_function = function(fig) {\n",
       "    return function socket_on_message(evt) {\n",
       "        if (evt.data instanceof Blob) {\n",
       "            /* FIXME: We get \"Resource interpreted as Image but\n",
       "             * transferred with MIME type text/plain:\" errors on\n",
       "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
       "             * to be part of the websocket stream */\n",
       "            evt.data.type = \"image/png\";\n",
       "\n",
       "            /* Free the memory for the previous frames */\n",
       "            if (fig.imageObj.src) {\n",
       "                (window.URL || window.webkitURL).revokeObjectURL(\n",
       "                    fig.imageObj.src);\n",
       "            }\n",
       "\n",
       "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
       "                evt.data);\n",
       "            fig.updated_canvas_event();\n",
       "            fig.waiting = false;\n",
       "            return;\n",
       "        }\n",
       "        else if (typeof evt.data === 'string' && evt.data.slice(0, 21) == \"data:image/png;base64\") {\n",
       "            fig.imageObj.src = evt.data;\n",
       "            fig.updated_canvas_event();\n",
       "            fig.waiting = false;\n",
       "            return;\n",
       "        }\n",
       "\n",
       "        var msg = JSON.parse(evt.data);\n",
       "        var msg_type = msg['type'];\n",
       "\n",
       "        // Call the  \"handle_{type}\" callback, which takes\n",
       "        // the figure and JSON message as its only arguments.\n",
       "        try {\n",
       "            var callback = fig[\"handle_\" + msg_type];\n",
       "        } catch (e) {\n",
       "            console.log(\"No handler for the '\" + msg_type + \"' message type: \", msg);\n",
       "            return;\n",
       "        }\n",
       "\n",
       "        if (callback) {\n",
       "            try {\n",
       "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
       "                callback(fig, msg);\n",
       "            } catch (e) {\n",
       "                console.log(\"Exception inside the 'handler_\" + msg_type + \"' callback:\", e, e.stack, msg);\n",
       "            }\n",
       "        }\n",
       "    };\n",
       "}\n",
       "\n",
       "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
       "mpl.findpos = function(e) {\n",
       "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
       "    var targ;\n",
       "    if (!e)\n",
       "        e = window.event;\n",
       "    if (e.target)\n",
       "        targ = e.target;\n",
       "    else if (e.srcElement)\n",
       "        targ = e.srcElement;\n",
       "    if (targ.nodeType == 3) // defeat Safari bug\n",
       "        targ = targ.parentNode;\n",
       "\n",
       "    // jQuery normalizes the pageX and pageY\n",
       "    // pageX,Y are the mouse positions relative to the document\n",
       "    // offset() returns the position of the element relative to the document\n",
       "    var x = e.pageX - $(targ).offset().left;\n",
       "    var y = e.pageY - $(targ).offset().top;\n",
       "\n",
       "    return {\"x\": x, \"y\": y};\n",
       "};\n",
       "\n",
       "/*\n",
       " * return a copy of an object with only non-object keys\n",
       " * we need this to avoid circular references\n",
       " * http://stackoverflow.com/a/24161582/3208463\n",
       " */\n",
       "function simpleKeys (original) {\n",
       "  return Object.keys(original).reduce(function (obj, key) {\n",
       "    if (typeof original[key] !== 'object')\n",
       "        obj[key] = original[key]\n",
       "    return obj;\n",
       "  }, {});\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.mouse_event = function(event, name) {\n",
       "    var canvas_pos = mpl.findpos(event)\n",
       "\n",
       "    if (name === 'button_press')\n",
       "    {\n",
       "        this.canvas.focus();\n",
       "        this.canvas_div.focus();\n",
       "    }\n",
       "\n",
       "    var x = canvas_pos.x * mpl.ratio;\n",
       "    var y = canvas_pos.y * mpl.ratio;\n",
       "\n",
       "    this.send_message(name, {x: x, y: y, button: event.button,\n",
       "                             step: event.step,\n",
       "                             guiEvent: simpleKeys(event)});\n",
       "\n",
       "    /* This prevents the web browser from automatically changing to\n",
       "     * the text insertion cursor when the button is pressed.  We want\n",
       "     * to control all of the cursor setting manually through the\n",
       "     * 'cursor' event from matplotlib */\n",
       "    event.preventDefault();\n",
       "    return false;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
       "    // Handle any extra behaviour associated with a key event\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.key_event = function(event, name) {\n",
       "\n",
       "    // Prevent repeat events\n",
       "    if (name == 'key_press')\n",
       "    {\n",
       "        if (event.which === this._key)\n",
       "            return;\n",
       "        else\n",
       "            this._key = event.which;\n",
       "    }\n",
       "    if (name == 'key_release')\n",
       "        this._key = null;\n",
       "\n",
       "    var value = '';\n",
       "    if (event.ctrlKey && event.which != 17)\n",
       "        value += \"ctrl+\";\n",
       "    if (event.altKey && event.which != 18)\n",
       "        value += \"alt+\";\n",
       "    if (event.shiftKey && event.which != 16)\n",
       "        value += \"shift+\";\n",
       "\n",
       "    value += 'k';\n",
       "    value += event.which.toString();\n",
       "\n",
       "    this._key_event_extra(event, name);\n",
       "\n",
       "    this.send_message(name, {key: value,\n",
       "                             guiEvent: simpleKeys(event)});\n",
       "    return false;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.toolbar_button_onclick = function(name) {\n",
       "    if (name == 'download') {\n",
       "        this.handle_save(this, null);\n",
       "    } else {\n",
       "        this.send_message(\"toolbar_button\", {name: name});\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n",
       "    this.message.textContent = tooltip;\n",
       "};\n",
       "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n",
       "\n",
       "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n",
       "\n",
       "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n",
       "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
       "    // object with the appropriate methods. Currently this is a non binary\n",
       "    // socket, so there is still some room for performance tuning.\n",
       "    var ws = {};\n",
       "\n",
       "    ws.close = function() {\n",
       "        comm.close()\n",
       "    };\n",
       "    ws.send = function(m) {\n",
       "        //console.log('sending', m);\n",
       "        comm.send(m);\n",
       "    };\n",
       "    // Register the callback with on_msg.\n",
       "    comm.on_msg(function(msg) {\n",
       "        //console.log('receiving', msg['content']['data'], msg);\n",
       "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
       "        ws.onmessage(msg['content']['data'])\n",
       "    });\n",
       "    return ws;\n",
       "}\n",
       "\n",
       "mpl.mpl_figure_comm = function(comm, msg) {\n",
       "    // This is the function which gets called when the mpl process\n",
       "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
       "\n",
       "    var id = msg.content.data.id;\n",
       "    // Get hold of the div created by the display call when the Comm\n",
       "    // socket was opened in Python.\n",
       "    var element = $(\"#\" + id);\n",
       "    var ws_proxy = comm_websocket_adapter(comm)\n",
       "\n",
       "    function ondownload(figure, format) {\n",
       "        window.open(figure.imageObj.src);\n",
       "    }\n",
       "\n",
       "    var fig = new mpl.figure(id, ws_proxy,\n",
       "                           ondownload,\n",
       "                           element.get(0));\n",
       "\n",
       "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
       "    // web socket which is closed, not our websocket->open comm proxy.\n",
       "    ws_proxy.onopen();\n",
       "\n",
       "    fig.parent_element = element.get(0);\n",
       "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
       "    if (!fig.cell_info) {\n",
       "        console.error(\"Failed to find cell for figure\", id, fig);\n",
       "        return;\n",
       "    }\n",
       "\n",
       "    var output_index = fig.cell_info[2]\n",
       "    var cell = fig.cell_info[0];\n",
       "\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_close = function(fig, msg) {\n",
       "    var width = fig.canvas.width/mpl.ratio\n",
       "    fig.root.unbind('remove')\n",
       "\n",
       "    // Update the output cell to use the data from the current canvas.\n",
       "    fig.push_to_output();\n",
       "    var dataURL = fig.canvas.toDataURL();\n",
       "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
       "    // the notebook keyboard shortcuts fail.\n",
       "    IPython.keyboard_manager.enable()\n",
       "    $(fig.parent_element).html('<img src=\"' + dataURL + '\" width=\"' + width + '\">');\n",
       "    fig.close_ws(fig, msg);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.close_ws = function(fig, msg){\n",
       "    fig.send_message('closing', msg);\n",
       "    // fig.ws.close()\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n",
       "    // Turn the data on the canvas into data in the output cell.\n",
       "    var width = this.canvas.width/mpl.ratio\n",
       "    var dataURL = this.canvas.toDataURL();\n",
       "    this.cell_info[1]['text/html'] = '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.updated_canvas_event = function() {\n",
       "    // Tell IPython that the notebook contents must change.\n",
       "    IPython.notebook.set_dirty(true);\n",
       "    this.send_message(\"ack\", {});\n",
       "    var fig = this;\n",
       "    // Wait a second, then push the new image to the DOM so\n",
       "    // that it is saved nicely (might be nice to debounce this).\n",
       "    setTimeout(function () { fig.push_to_output() }, 1000);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_toolbar = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var nav_element = $('<div/>');\n",
       "    nav_element.attr('style', 'width: 100%');\n",
       "    this.root.append(nav_element);\n",
       "\n",
       "    // Define a callback function for later on.\n",
       "    function toolbar_event(event) {\n",
       "        return fig.toolbar_button_onclick(event['data']);\n",
       "    }\n",
       "    function toolbar_mouse_event(event) {\n",
       "        return fig.toolbar_button_onmouseover(event['data']);\n",
       "    }\n",
       "\n",
       "    for(var toolbar_ind in mpl.toolbar_items){\n",
       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
       "\n",
       "        if (!name) { continue; };\n",
       "\n",
       "        var button = $('<button class=\"btn btn-default\" href=\"#\" title=\"' + name + '\"><i class=\"fa ' + image + ' fa-lg\"></i></button>');\n",
       "        button.click(method_name, toolbar_event);\n",
       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
       "        nav_element.append(button);\n",
       "    }\n",
       "\n",
       "    // Add the status bar.\n",
       "    var status_bar = $('<span class=\"mpl-message\" style=\"text-align:right; float: right;\"/>');\n",
       "    nav_element.append(status_bar);\n",
       "    this.message = status_bar[0];\n",
       "\n",
       "    // Add the close button to the window.\n",
       "    var buttongrp = $('<div class=\"btn-group inline pull-right\"></div>');\n",
       "    var button = $('<button class=\"btn btn-mini btn-primary\" href=\"#\" title=\"Stop Interaction\"><i class=\"fa fa-power-off icon-remove icon-large\"></i></button>');\n",
       "    button.click(function (evt) { fig.handle_close(fig, {}); } );\n",
       "    button.mouseover('Stop Interaction', toolbar_mouse_event);\n",
       "    buttongrp.append(button);\n",
       "    var titlebar = this.root.find($('.ui-dialog-titlebar'));\n",
       "    titlebar.prepend(buttongrp);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._root_extra_style = function(el){\n",
       "    var fig = this\n",
       "    el.on(\"remove\", function(){\n",
       "\tfig.close_ws(fig, {});\n",
       "    });\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._canvas_extra_style = function(el){\n",
       "    // this is important to make the div 'focusable\n",
       "    el.attr('tabindex', 0)\n",
       "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
       "    // off when our div gets focus\n",
       "\n",
       "    // location in version 3\n",
       "    if (IPython.notebook.keyboard_manager) {\n",
       "        IPython.notebook.keyboard_manager.register_events(el);\n",
       "    }\n",
       "    else {\n",
       "        // location in version 2\n",
       "        IPython.keyboard_manager.register_events(el);\n",
       "    }\n",
       "\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
       "    var manager = IPython.notebook.keyboard_manager;\n",
       "    if (!manager)\n",
       "        manager = IPython.keyboard_manager;\n",
       "\n",
       "    // Check for shift+enter\n",
       "    if (event.shiftKey && event.which == 13) {\n",
       "        this.canvas_div.blur();\n",
       "        // select the cell after this one\n",
       "        var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
       "        IPython.notebook.select(index + 1);\n",
       "    }\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
       "    fig.ondownload(fig, null);\n",
       "}\n",
       "\n",
       "\n",
       "mpl.find_output_cell = function(html_output) {\n",
       "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
       "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
       "    // IPython event is triggered only after the cells have been serialised, which for\n",
       "    // our purposes (turning an active figure into a static one), is too late.\n",
       "    var cells = IPython.notebook.get_cells();\n",
       "    var ncells = cells.length;\n",
       "    for (var i=0; i<ncells; i++) {\n",
       "        var cell = cells[i];\n",
       "        if (cell.cell_type === 'code'){\n",
       "            for (var j=0; j<cell.output_area.outputs.length; j++) {\n",
       "                var data = cell.output_area.outputs[j];\n",
       "                if (data.data) {\n",
       "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
       "                    data = data.data;\n",
       "                }\n",
       "                if (data['text/html'] == html_output) {\n",
       "                    return [cell, data, j];\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    }\n",
       "}\n",
       "\n",
       "// Register the function which deals with the matplotlib target/channel.\n",
       "// The kernel may be null if the page has been refreshed.\n",
       "if (IPython.notebook.kernel != null) {\n",
       "    IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n",
       "}\n"
      ],
      "text/plain": [
       "<IPython.core.display.Javascript object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<img src=\"\" width=\"1120\">"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "backInTime = 400\n",
    "z = np.linspace(1,1000,1000)\n",
    "%matplotlib notebook\n",
    "import matplotlib.pyplot as plt\n",
    "@interact(ts=(0,len(X)-1,30),xloc=(-1000,7000,50),zoom=(-5000,5000,100))\n",
    "def plot_clines(ts=0,xloc=0,zoom=-2000):\n",
    "    from mpl_toolkits import mplot3d\n",
    "\n",
    "\n",
    "    fig = plt.figure(num=None, figsize=(14, 6), dpi=80, facecolor='w', edgecolor='k')\n",
    "    ax = plt.axes(projection='3d')\n",
    "#     plt.text(0.01, 0.95, 'Timestep: ' + str(TIME[ts]), horizontalalignment='left', verticalalignment='top', transform=ax.transAxes, fontsize=28)\n",
    "#     plt.text(.025, .57, 'Flow', horizontalalignment='left', verticalalignment='bottom', fontsize=20, transform=ax.transAxes)\n",
    "#     ax.arrow(.005, .55, .1,0, width = .01, head_width=.05, head_length=.01, fc='k', ec='k', transform=ax.transAxes)\n",
    "\n",
    "    startTime = np.max(np.array([0,ts-backInTime]))\n",
    "    for i in np.arange(startTime,ts,20):\n",
    "        ax.plot3D(X[i],Y[i],z[i],lw=1,color=(0.5,0.5,0.5))\n",
    "    for i in np.arange(startTime,ts,1):\n",
    "        if np.any(~np.isnan(OXBOWX[i])):\n",
    "            ax.plot3D(OXBOWX[i],OXBOWY[i],z[i],lw=2,color=(1,.7,0))\n",
    "        \n",
    "    ax.plot3D(X[ts],Y[ts],z[ts],lw=2,color=(0.04,0.37,0.59))\n",
    "    ax.plot3D(X1[ts],Y1[ts],z[ts],lw=2,color=(1,0,0))\n",
    "    ax.plot3D(X2[ts],Y2[ts],z[ts],lw=2,color=(0,1,0))\n",
    "    ax.plot3D(OXBOWX[ts],OXBOWY[ts],z[ts],lw=6,color=(1,.7,0))\n",
    "#     ax.xticks([]) \n",
    "#     ax.yticks([])\n",
    "#     plt.zticks([])\n",
    "    ax.set_xlim(xloc,np.max(X[0][-1])+800)\n",
    "    ax.set_ylim(-(3000-zoom)/3.0,(3000-zoom)/3.0)\n",
    "#     ax.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x202b068d7c8>"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
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1Ut+7vVtvAYcAR4W8d9OfI9Bu6u+vIp4OYu46za/wb4w4FlO+vPuj+eiSlJhfJMTEkqlAlckgplApekQpnAJalQJnBJKpQJXJIKZQKXpEKZwCWpUP8P9Oassd7wlNMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# How do you find all the points lying inside the channel boundaries: 2D\n",
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib\n",
    "\n",
    "X2r = [elem[::-1] for elem in X2]\n",
    "Y2r = [elem[::-1] for elem in Y2]\n",
    "\n",
    "# x = [16,121,180,0]; y = [152,153,182,0]\n",
    "x = np.hstack((X1[600], X2r[600])); y = np.hstack((Y1[600], Y2r[600]));\n",
    "xy = np.array([x,y]).T\n",
    "# print(xy.shape)\n",
    "p = matplotlib.patches.Polygon(xy)\n",
    "\n",
    "\n",
    "x, y = np.meshgrid(np.arange(0,10000,50), np.arange(-1500,1500,50)) # make a canvas with coordinates\n",
    "x, y = x.flatten(), y.flatten()\n",
    "points = np.vstack((x,y)).T \n",
    "\n",
    "\n",
    "grid = p.contains_points(points)\n",
    "mask = grid.reshape(60,200) # now you have a mask with points inside a polygon\n",
    "plt.imshow(mask)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
